package cn.stylefeng.guns.modular.gridsystem.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import cn.stylefeng.guns.modular.gridsystem.model.param.GatewayFirmwareParam;
import cn.stylefeng.guns.modular.gridsystem.service.GatewayFirmwareService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 网关固件表 控制器
 *
 * @author: zxw
 * @date: 2022/11/03 11:41
 */
@RestController
@RequiredArgsConstructor
public class GatewayFirmwareController {

    private final GatewayFirmwareService gatewayFirmwareService;

    /**
     * 分页查询网关固件表
     *
     * @author zxw
     * @date 2022/11/03 11:41
     */
    @GetMapping("/gatewayFirmware/page")
    @BusinessLog(title = "网关固件表_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(GatewayFirmwareParam gatewayFirmwareParam) {
        return new SuccessResponseData(gatewayFirmwareService.page(gatewayFirmwareParam));
    }

    /**
     * 获取全部网关固件表
     *
     * @author zxw
     * @date 2022/11/03 11:41
     */
    @GetMapping("/gatewayFirmware/list")
    @BusinessLog(title = "网关固件表_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(GatewayFirmwareParam gatewayFirmwareParam) {
        return new SuccessResponseData(gatewayFirmwareService.list(gatewayFirmwareParam));
    }

    /**
     * 查看详情网关固件表
     *
     * @author zxw
     * @date 2022/11/03 11:41
     */
    @GetMapping("/gatewayFirmware/detail")
    @BusinessLog(title = "网关固件表_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(GatewayFirmwareParam.detail.class) GatewayFirmwareParam gatewayFirmwareParam) {
        return new SuccessResponseData(gatewayFirmwareService.detail(gatewayFirmwareParam));
    }

    /**
     * 添加网关固件表
     *
     * @author zxw
     * @date 2022/11/03 11:41
     */
    @PostMapping("/gatewayFirmware/add")
    @BusinessLog(title = "网关固件表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(GatewayFirmwareParam.add.class) GatewayFirmwareParam gatewayFirmwareParam) {
        gatewayFirmwareService.add(gatewayFirmwareParam);
        return new SuccessResponseData();
    }

    /**
     * 删除网关固件表
     *
     * @author zxw
     * @date 2022/11/03 11:41
     */
    @PostMapping("/gatewayFirmware/delete")
    @BusinessLog(title = "网关固件表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(GatewayFirmwareParam.delete.class) GatewayFirmwareParam gatewayFirmwareParam) {
        gatewayFirmwareService.delete(gatewayFirmwareParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑网关固件表
     *
     * @author zxw
     * @date 2022/11/03 11:41
     */
    @PostMapping("/gatewayFirmware/edit")
    @BusinessLog(title = "网关固件表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(GatewayFirmwareParam.edit.class) GatewayFirmwareParam gatewayFirmwareParam) {
        gatewayFirmwareService.edit(gatewayFirmwareParam);
        return new SuccessResponseData();
    }


}
